/**
 * 
 */
package com.bg.algorithms.sort;

import com.bg.algorithms.util.PrintUtil;

/**
 * @author fassmus
 * 
 */
public class InsertinSort extends AbstractSort {

	public InsertinSort(boolean print) {
		super(print);
	}

	public void insertinSort(int[] inputNumbers) {
		for (int j = 1; j < inputNumbers.length; j++) {
			int key = inputNumbers[j];
			int i = j - 1;
			while (i >= 0 && inputNumbers[i] > key) {
				inputNumbers[i + 1] = inputNumbers[i];
				i = i - 1;
			}
			inputNumbers[i + 1] = key;
		}

		if (isPrint()) {
			PrintUtil.printNumers(inputNumbers);
		}
	}

}
